package com.java.simple.study.jvm.memstruct.directmemory;

import com.java.simple.study.tool.UnsafeUtil;
import sun.misc.Unsafe;

import java.io.IOException;

/**
 * @author zhoujunlin
 * @date 2021/12/15
 * @desc
 **/
public class Demo4_4 {

    static int _1GB = 1024 * 1024 * 1024;

    public static void main(String[] args) throws IOException {
        Unsafe unsafe = UnsafeUtil.getUnsafe();

        long allocateMemoryAddr = unsafe.allocateMemory(_1GB);
        unsafe.setMemory(allocateMemoryAddr, _1GB, (byte) 0);
        System.in.read();

        unsafe.freeMemory(allocateMemoryAddr);
        System.in.read();
    }

}
